Conversation
|
I like the look of this, along with how many variants we have open still. Also, I believe we should be able to make a tt muncher macro that will generate our value variants with a syntax such as the following: scuffed_enum! {
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(u8)])
enum Value {
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(u8)]
enum Thrown? {
Undefined = 1,
Null,
// ...
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(u8)]
enum String {
Index(StringIndex),
Small(SmallString),
}
// ...
}
EmbedderObject,
Reference,
}
}Which would recursively build all of our enum types and Edit: It could also be really cool if we could have |
|
A macro would probably be useful, yeah. I think we have some cases where it wouldn't work though; mainly I'm thinking of I expect that with private properties we'll want to introduce a Additionally: Due to the This isn't too much of an issue though: It just means that Regarding Promise variants, I don't think that's possible or reasonable. For one it would take up most of the variants we have left. There's still a wealth of ES proposals out there in the world and they bring in extra spec items that require variants; we can't eat them all up :) (Though if we really run out we can bump up to 16 bit variants and then we're golden forever.) But most importantly: I'm not sure what the benefit would be. What's the difference between a eg. Every place that keeps |
I tried sketching out all Value "enum-space" variants that I could squeeze out of the ECMAScript spec. Some of these I'm not even sure if they're truly possible, mainly the generator functions vs iterators I'm not sure if they're the same thing or not. (
AsyncFromSyncIteratoris explicitly mentioned to not be observable by user code.)Anyway, the end result was that with this absolutely bloated selection of variants we have a total of 56 different Value variants, an equal amount of thrown variants of course, 0 for None and 0x80 for ReferenceRecord. With a u8 repr we can afford 127 Value variants in total if we have thrown variants as well, so this would be 44.5% of the way to us being full. Put another way, we have 71 variants open. This number can be increased by eg. combining primitive value objects into a single variant, combining TypedArrays into a single variant, combining functions into less variants (it's very much debatable if all the different versions are all that useful). That would give us about 20 more variants.
So anyway, does this spark any ideas? Anything I've missed? Something that obviously doesn't make sense?